package com.finance.system.user.controller;


import com.finance.system.configure.websecurity.AuthUser;
import com.finance.system.user.entity.UserEntity;
import com.finance.system.user.entity.UserExtendEntity;
import com.finance.system.user.entity.UserInfo;
import com.finance.system.user.entity.UserOutbound;
import com.finance.system.user.service.IUserExtendService;
import com.finance.system.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表，存放系统用户信息 前端控制器
 * </p>
 *
 * @author whdong
 * @since 2019-12-24
 */
@RestController
@RequestMapping("/user")
@Api(description = "用户模块",tags = "用户信息")
public class UserController extends BaseController {
    @Autowired
    private IUserExtendService userExtendService;
    @Autowired
    private IUserService userService;

    @GetMapping("landedUser")
    @ApiOperation("登陆用户信息")
    public UserOutbound landedUser(@AuthUser UserInfo userInfo){
        UserEntity user = userService.getById(userInfo.getId());
        UserExtendEntity userExtend = userExtendService.getByUserId(userInfo.getId());
        UserOutbound userOutbound = new UserOutbound();
        BeanUtils.copyProperties(user,userOutbound);
        BeanUtils.copyProperties(userExtend,userOutbound);
        return userOutbound;
    }
}
